<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="12">
          <a-col :xl="5" :lg="6" :md="7" :sm="24">
            <a-form-item :label="$t('商品形态')" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-select v-model="queryParam.form">
                <a-select-option v-for="item in list" :key="item.value" :value="item.value">{{
                  item.title
                }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item :label="$t('商品信息')" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :placeholder="$t('请输入商品编码/名称/条码')" v-model="queryParam.goodsInfo"></a-input>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="5" :lg="6" :md="7" :sm="24">
              <a-form-item :label="$t('上架状态')" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-select v-model="queryParam.state" @change="handleChange">
                  <a-select-option value="">{{ $t('全部') }}</a-select-option>
                  <a-select-option value="Y">{{ $t('是') }}</a-select-option>
                  <a-select-option value="N">{{ $t('否') }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item :label="$t('销售兑换方式')" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-select v-model="sales" @change="handleChangeSales">
                  <a-select-option value="">{{ $t('全部') }}</a-select-option>
                  <a-select-option value="allowAlottery">{{ $t('允许A票兑换') }}</a-select-option>
                  <a-select-option value="allowCoin">{{ $t('允许币兑换') }}</a-select-option>
                  <a-select-option value="allowIntegral">{{ $t('允许积分兑换') }}</a-select-option>
                  <a-select-option value="allowLottery">{{ $t('允许彩票兑换') }}</a-select-option>
                  <a-select-option value="allowMemberDiscount">{{ $t('允许享受会员优惠') }}</a-select-option>
                  <a-select-option value="allowOut">{{ $t('允许0库存出库') }}</a-select-option>
                  <a-select-option value="allowPoints">{{ $t('允许A币兑换') }}</a-select-option>
                  <a-select-option value="allowSale">{{ $t('允许销售') }}</a-select-option>
                  <a-select-option value="allowWarn">{{ $t('开启缺货提示') }}</a-select-option>
                  <a-select-option value="allowRecycle">{{ $t('允许回收') }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item :label="$t('供应商')">
                <j-dict-select-tag
                  :placeholder="$t('请选择供应商')"
                  v-model="queryParam.supplierId"
                  dictCode="bis_goods_supplier,name,id"
                />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item>
                <div>
                  <a-select v-model="queryParam.newType" style="width: 29%; margin-right: 1%">
                    <a-select-option v-for="(item, i) in dictOptions.typeList" :key="i" :value="item.value">{{
                      $t(item.text)
                    }}</a-select-option>
                  </a-select>
                  <a-input-number v-model="queryParam[queryParam.newType+'_begin']" style="width: 32%; margin-right: 1%" />
                  <span>~</span>
                  <a-input-number v-model="queryParam[queryParam.newType+'_end']" style="width: 32%; margin-left: 1%" />
                </div>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24" v-if="!tenantid">
              <a-form-item :label="$t('门店')">
                <a-select v-model="queryParam.tenantId">
                  <a-select-option v-for="(item, i) in shops" :key="i" :value="item.value"
                    >{{ item.title }}<span v-if="item.value != ''&&item.value != '0'">（{{ item.value }}）</span></a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="8" :md="12" :sm="24">
            <span class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">{{ $t('查询') }}</a-button>
              <a-button type="primary" @click="handleReset" icon="reload" style="margin-left: 8px">{{
                $t('重置')
              }}</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? $t('收起') : $t('展开') }}<a-icon :type="toggleSearchStatus ? 'up' : 'down'"
              /></a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div class="table-operator">
      <a-dropdown>
        <a-button type="primary" v-has="'BisGoodsInforController:print'">{{ $t('标签打印') }}</a-button>
        <a-menu slot="overlay">
          <a-menu-item>
            <a @click="printSetting">{{ $t('打印机设置') }}</a>
          </a-menu-item>
          <a-menu-item>
            <a @click="clickBatchPrint">{{ $t('批量打印') }}</a>
          </a-menu-item>
        </a-menu>
      </a-dropdown>
      <a-button type="primary" @click="clickBatchEdit" v-has="'BisGoodsInforController:edit'">{{ $t('批量修改') }}</a-button>
      <a-button type="primary" @click="batchDel" v-has="'BisGoodsInforController:delete'">{{ $t('批量删除') }}</a-button>
      <a-popover :title="$t('自定义列')" trigger="click" placement="bottom">
        <template slot="content">
          <a-checkbox-group
            @change="onColSettingsChange"
            v-model="settingColumns"
            :defaultValue="settingColumns"
          >
            <a-row style="width: 400px">
              <template v-for="(item, i) in defColumns">
                <template v-if="item.key != 'rowIndex' && item.dataIndex != 'action'">
                  <a-col :span="12" :key="i"
                    ><a-checkbox :value="item.dataIndex"
                      ><j-ellipsis :value="item.title" :length="10"></j-ellipsis></a-checkbox
                  ></a-col>
                </template>
              </template>
            </a-row>
          </a-checkbox-group>
        </template>
        <a-button type="primary">{{ $t('设置列') }}</a-button>
      </a-popover>
      <a-button type="primary" icon="download" @click="handleExportXls('商品资料')" v-has="'BisGoodsInforController:export'">{{ $t('导出') }}</a-button>
      <a-button type="primary" icon="import" @click="getImport" v-has="'BisGoodsInforController:import'">{{ $t('导入') }}</a-button>
      <a-button @click="handleAdd" type="primary" icon="plus" v-has="'BisGoodsInforController:add'">{{ $t('新增') }}</a-button>
    </div>
    <a-row style="border: 1px solid #d9d9d9">
      <a-col :span="3" style="border-right: 1px solid #d9d9d9; overflow: auto" :style="{ 'max-height': height + 'px' }">
        <a-tree
          ref="treeBox"
          :tree-data="sortData"
          :props="defaultProps"
          style="background-color: #fff"
          :defaultSelectedKeys="defaultSelectedKeys"
          @select="treeSelect"
        />
      </a-col>
      <a-col :span="21" style="border-left: 1px solid #d9d9d9; overflow: auto" :style="{ 'max-height': height + 'px' }">
        <a-row>
          <a-table
            ref="table"
            size="middle"
            :scroll="{ x: true }"
            bordered
            rowKey="id"
            class="j-table-force-nowrap"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            :rowSelection="rowSelection"
            @change="handleTableChange"
          >
            <template slot="imgSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
              <div v-else>
                <a-popover trigger="hover" v-for="(item,i) in text.split(',')" :key="i">
                  <template slot="content">
                    <img :src="getImgView(item)" width="240px" />
                  </template>
                  <img   
                    :src="getImgView(item)"
                    height="25px"
                    alt=""
                    style="max-width:80px;font-size: 12px;font-style: italic;margin-right: 5px;"
                  />
                </a-popover>
              </div>
            </template>
            <span
              slot="action"
              slot-scope="text, record"
              v-if="(!record.tenantId && !tenantid) || record.tenantId == tenantid"
            >
              <a-popconfirm
                v-if="record.state == 'Y'"
                :title="$t('确定下架吗?')"
                @confirm="() => changeStatus(record.id, record.state)"
              >
                <a v-has="'BisGoodsInforController:edit'">{{ $t('下架') }}</a>
              </a-popconfirm>
              <a-popconfirm
                v-if="record.state == 'N'"
                :title="$t('确定上架吗?')"
                @confirm="() => changeStatus(record.id, record.state)"
              >
                <a v-has="'BisGoodsInforController:edit'">{{ $t('上架') }}</a>
              </a-popconfirm>
              <a-divider type="vertical" v-has="'BisGoodsInforController:edit'"/>
              <span v-has="'BisGoodsInforController:edit'">
                <a @click="handleEditCon(record)" v-if="record.form == '9'">{{ $t('编辑') }}</a>
                <a @click="handleEditTimeLimitCoin(record)" v-else-if="record.form == '15'">{{ $t('编辑') }}</a>
                <a @click="handleEditACoin(record)" v-else-if="record.form == '14'">{{ $t('编辑') }}</a>
                <a
                  @click="handleEditToken(record)"
                  v-else-if="record.form == '7' || record.form == '13' || record.form == '16'"
                  >{{ $t('编辑') }}</a
                >
                <a @click="handleEditCard(record)" v-else-if="record.form == '20'">{{  $t('编辑') }}</a>
                <a @click="handleEdit(record)" v-else>{{ $t('编辑') }}</a>
              </span>
              <a-divider type="vertical" v-if="record.form != '7' && record.form != '13' && record.form != '16' && record.form != '20'" v-has="'BisGoodsInforController:edit'" />
              <a-popconfirm :title="$t('确定删除吗?')" @confirm="() => handleDelete(record.id)">
                <a v-if="record.form != '7' && record.form != '13' && record.form != '16' && record.form != '20'" v-has="'BisGoodsInforController:delete'">{{ $t('删除') }}</a>
              </a-popconfirm>
              <a-divider type="vertical" />
              <span>
                <a @click="handleEditCon(record, true)" v-if="record.form == '9'">{{ $t('详情') }}</a>
                <a @click="handleEditTimeLimitCoin(record, true)" v-else-if="record.form == '15'">{{ $t('详情') }}</a>
                <a @click="handleEditACoin(record, true)" v-else-if="record.form == '14'">{{ $t('详情') }}</a>
                <a @click="handleEditToken(record, true)" v-else-if="record.form == '7' || record.form == '13' || record.form == '16'" >{{ $t('详情') }}</a>
                <a @click="handleEditCard(record)" v-else-if="record.form == '20'">{{  $t('详情') }}</a>
                <a @click="handleEdit(record, true)" v-else>{{ $t('详情') }}</a>
              </span>
            </span>
            <span slot="action" slot-scope="text, record" v-else>
              <span>
                <a @click="handleEditCon(record, true)" v-if="record.form == '9'">{{ $t('详情') }}</a>
                <a @click="handleEditTimeLimitCoin(record, true)" v-else-if="record.form == '15'">{{ $t('详情') }}</a>
                <a @click="handleEditACoin(record, true)" v-else-if="record.form == '14'">{{ $t('详情') }}</a>
                <a @click="handleEditToken(record, true)" v-else-if="record.form == '7' || record.form == '13' || record.form == '16'">{{ $t('详情') }}</a>
                <a @click="handleEditCard(record)" v-else-if="record.form == '20'">{{  $t('详情') }}</a>
                <a @click="handleEdit(record, true)" v-else>{{ $t('详情') }}</a>
              </span>
            </span>
            <template v-for="col in ['sort']" :slot="col" slot-scope="text, record">
              <div :key="col" style="display: flex; justify-content: center">
                <div>
                  <a-input
                    v-if="record.editable"
                    style="margin: -5px 0; padding: 0; width: 50px"
                    :value="text"
                    @change="(e) => handleChange(e.target.value, record.id, col)"
                    :maxLength="3"
                  />
                  <template v-else>{{ text }}</template>
                </div>
                <div class="editable-row-operations">
                  <span v-if="record.editable">
                    <a @click="() => save(record.id)"><a-icon type="save" /></a>
                  </span>
                  <span v-else>
                    <a :disabled="editingKey !== ''" @click="() => edit(record, record.id)"><a-icon type="edit" /></a>
                  </span>
                </div>
              </div>
            </template>
          </a-table>
        </a-row>
      </a-col>
    </a-row>
    <!-- 导入弹窗 -->
    <a-modal
      :title="$t('导入商品')"
      :visible="visible"
      :destroyOnClose="destroyOnClose"
      :confirm-loading="confirmLoading"
      :okText="$t('确定')"
      :cancelText="$t('取消')"
      :width="modal_width"
      :cancel-button-props="cancelbutton"
      @ok="handleOk"
      @cancel="handleCancel"
    >
      <a-form-model ref="ruleForm" :model="ruleForm" :rules="rules" v-bind="layout">
        <a-form-model-item :label="$t('导入模板')">
          <a-button type="primary" icon="download" @click="download($t('商品信息导入模板'))">{{
            $t('下载模板')
          }}</a-button>
        </a-form-model-item>
        <a-form-model-item :label="$t('导入文件')" prop="name">
          <a-input-group compact>
            <a-input
              style="width: 80%"
              v-model="ruleForm.name"
              :placeholder="$t('请选择要导入的商品信息文件')"
              disabled
            ></a-input>
            <a-upload
              name="file"
              :showUploadList="false"
              :action="importExcelUrl"
              :multiple="false"
              :headers="tokenHeader"
              @change="handleImportExcel1"
            >
              <a-button style="background-color: #f59a23; color: #ffffff">{{ $t('选择') }}</a-button>
            </a-upload>
          </a-input-group>
        </a-form-model-item>
      </a-form-model>
    </a-modal>
    <a-modal
      :zIndex="zIndex"
      :title="$t('新增商品')"
      width="700px"
      :visible="visible1"
      :confirmLoading="confirmLoading1"
      @cancel="handleCancel1"
      :cancelText="$t('关闭')"
      :destroyOnClose="destroyOnClose"
      v-drag
    >
      <template slot="footer">
        <a-button @click="handleCancel1">{{ $t('取消') }}</a-button>
      </template>
      <a-spin :spinning="confirmLoading1">
        <div>
          <a-row :gutter="24">
            <a-col
              :span="6"
              v-for="(item, indexs) in list1"
              :key="indexs"
              class="top-col"
              @click="handleAdd1(item.value)"
              >{{ item.title }}</a-col
            >
          </a-row>
        </div>
      </a-spin>
    </a-modal>
    <goods-info-modal ref="modalForm" @ok="modalFormOk" />
    <coupons-modal ref="conponsForm" @ok="modalFormOk" />
    <token-modal ref="tokenForm" @ok="modalFormOk" />
    <goods-info-a-coin-modal ref="aCoinModalForm" @ok="modalFormOk" />
    <goods-info-a-lottery-modal ref="aLotteryModalForm" @ok="modalFormOk" />
    <time-limit-coin-modal ref="timeLimitCoin" @ok="modalFormOk" />
    <card-modal ref="cardForm" @ok="modalFormOk" />
    <goods-info-meal-modal ref="goodsInfoMeal" @ok="modalFormOk" />
    <batch-edit-sales-modal ref="modalForm1" @ok="modalFormOk" />
    <print-setting ref="printSet" @ok="modalFormOk" />
    <batch-print ref="batchPrint" @ok="modalFormOk" />
    <digital-coin-modal ref="digitalCoin" @ok="modalFormOk" />
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import Vue from 'vue'
import { getAction, deleteAction, putAction, downFile, UploadFile, getFileAccessHttpUrl } from '@/api/manage'
import { filterMultiDictText, initDictOptions } from '@/components/dict/JDictSelectUtil'
import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types'
import PrintSetting from './modules/PrintSetting'
import BatchPrint from './modules/BatchPrint'
import BatchEditSalesModal from './modules/BatchEditSalesModal'
import TokenModal from './modules/TokenModal'
import CardModal from './modules/CardModal'
import CouponsModal from './modules/CouponsModal'
import GoodsInfoModal from './modules/GoodsInfoModal'
import GoodsInfoACoinModal from './modules/GoodsInfoACoinModal'
import GoodsInfoALotteryModal from './modules/GoodsInfoALotteryModal'
import TimeLimitCoinModal from './modules/TimeLimitCoinModal'
import GoodsInfoMealModal from './modules/GoodsInfoMealModal'
import DigitalCoinModal from './modules/DigitalCoinModal'

export default {
  name: 'GoodsInfo',
  components: {
    PrintSetting,
    BatchPrint,
    BatchEditSalesModal,
    TokenModal,
    CardModal,
    CouponsModal,
    GoodsInfoModal,
    GoodsInfoACoinModal,
    GoodsInfoALotteryModal,
    TimeLimitCoinModal,
    GoodsInfoMealModal,
    DigitalCoinModal
  },
  data() {
    return {
      description: '商品资料设置管理页面',
      loading: false,
      dataSource: [],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 18 },
      },
      editingKey: '',
      index: 0,
      sortList: [],
      queryParam: {
        goodsInfo: '',
        form: '',
        state: '',
        notSystem: 1,
        tenantId: '',
        newType: 'price'
      },
      sales: '',
      //列设置
      settingColumns: [],
      // 表头
      columns: [],
      //列定义
      defColumns: [
        {
          title: this.$t('排序序号'),
          dataIndex: 'sort',
          align: 'right',
          scopedSlots: { customRender: 'sort' },
          customCell: () => {
            return {
              style: {
                width: '80px',
              },
            }
          },
        },
        {
          title: this.$t('商品形态'),
          align: 'center',
          dataIndex: 'form_dictText',
        },
        {
          title: this.$t('商品编码'),
          align: 'center',
          dataIndex: 'code',
          sorter: true,
        },
        {
          title: this.$t('商品条码'),
          align: 'center',
          dataIndex: 'barCode',
        },
        {
          title: this.$t('商品名称'),
          align: 'center',
          dataIndex: 'name',
          customCell: () => {
            return {
              style: {
                wordWrap: 'break-word',
                wordBreak: 'normal',
                whiteSpace: 'pre-wrap',
                maxWidth: '400px',
              },
            }
          },
          sorter: true,
        },
        {
          title: this.$t('商品分类'),
          align: 'center',
          dataIndex: 'kindName',
        },
        {
          title: this.$t('供应商'),
          align: 'center',
          dataIndex: 'supplierId_dictText',
        },
        {
          title: this.$t('上架状态'),
          align: 'center',
          dataIndex: 'state',
          customRender: (text,r) => (r.state_dictText),
        },
        {
          title: this.$t('参考成本'),
          align: 'right',
          dataIndex: 'cost',
          sorter: true,
          customRender: (text, r) => {
            return r.cost.toFixed(2);
          }
        },
        {
          title: this.$t('是否允许销售'),
          align: 'center',
          dataIndex: 'allowSale',
          customRender: (text,r) => (r.allowSale_dictText),
        },
        {
          title: this.$t('售价'),
          align: 'right',
          dataIndex: 'price',
          sorter: true,
          customRender: (text, r) => {
            return r.price.toFixed(2);
          }
        },
        {
          title: this.$t('允许币兑换'),
          align: 'right',
          dataIndex: 'allowCoin',
          customRender:(t,r)=>{
            return r.allowCoin_dictText
          }
        },
        {
          title: this.$t('币兑换值'),
          align: 'right',
          dataIndex: 'coin',
          sorter: true
        },
        {
          title: this.$t('允许彩票兑换'),
          align: 'right',
          dataIndex: 'allowLottery',
          customRender:(t,r)=>{
            return r.allowLottery_dictText
          }
        },
        {
          title: this.$t('彩票兑换值'),
          align: 'right',
          dataIndex: 'lottery',
          sorter: true
        },
        {
          title: this.$t('允许A票兑换'),
          align: 'right',
          dataIndex: 'allowAlottery',
          customRender:(t,r)=>{
            return r.allowAlottery_dictText
          }
        },
        {
          title: this.$t('A票兑换值'),
          align: 'right',
          dataIndex: 'alottery',
          sorter: true
        },
        {
          title: this.$t('允许A币兑换'),
          align: 'right',
          dataIndex: 'allowPoints',
          customRender:(t,r)=>{
            return r.allowPoints_dictText
          }
        },
        {
          title: this.$t('A币兑换值'),
          align: 'right',
          dataIndex: 'points',
          sorter: true
        },
        {
          title: this.$t('允许积分兑换'),
          align: 'right',
          dataIndex: 'allowIntegral',
          customRender:(t,r)=>{
            return r.allowIntegral_dictText
          }
        },
        {
          title: this.$t('积分兑换值'),
          align: 'right',
          dataIndex: 'integral',
          sorter: true
        },
        {
          title: this.$t('商品图片'),
          align: 'center',
          dataIndex: 'picture',
          scopedSlots: { customRender: 'imgSlot' },
        },
        {
          title: this.$t('操作'),
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/goods/bisGoodsInfor/list',
        delete: '/goods/bisGoodsInfor/delete',
        deleteBatch: '/goods/bisGoodsInfor/deleteBatch',
        exportXlsUrl: '/goods/bisGoodsInfor/exportXls',
        importExcelUrl: 'sys/common/upload',
      },
      dictOptions: {},
      sortData: [],
      sortId: 0,
      defaultProps: {
        children: 'children',
        label: 'label',
      },
      tableColumns: [],
      list: [],
      rootItem: {},
      selectedRowKeys: [],
      selectionRows: [],
      treeItem: 0,
      defaultSelectedKeys: [],
      allChildKind: [],
      batchList: [],
      ipagination: {
        current: 1,
        pageSize: 30,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + this.$t('sum-total', { total: total })
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0,
        onShowSizeChange: (current, pageSize) => this.handleSizeChange(current, pageSize),
      },
      toggleSearchStatus: true,
      // 导入弹窗
      visible: false,
      destroyOnClose: true,
      confirmLoading: false,
      cancelbutton: { props: { disabled: false } },
      modal_width: '700px',
      ruleForm: {
        filename: '',
        name: '',
      },
      rules: {
        name: [{ required: true, message: this.$t('请选择导入文件'), trigger: 'blur' }],
      },
      layout: {
        labelCol: { span: 5 },
        wrapperCol: { span: 16 },
      },
      visible1: false,
      confirmLoading1: false,
      list1: [],
      isorter: {
        column: 'sort',
        order: 'asc',
      },
      height: 400,
      zIndex: 1000,
      shops: [],
      tenantid: Vue.ls.get(TENANT_ID),
      taxSetting: localStorage.getItem('taxSetting')
    }
  },
  created() {
    this.taxSetting = localStorage.getItem('taxSetting')
    let arr = [
      { text: this.$t('是'), value: 'Y' },
      { text: this.$t('否'), value: 'N' },
    ]
    this.$set(this.dictOptions, 'allowOut', arr)
    this.$set(this.dictOptions, 'state', arr)
    this.$set(this.dictOptions, 'allowWarn', arr)
    this.$set(this.dictOptions, 'allowSale', arr)
    this.$set(this.dictOptions, 'allowIntegral', arr)
    this.$set(this.dictOptions, 'allowCoin', arr)
    this.$set(this.dictOptions, 'allowLottery', arr)
    this.$set(this.dictOptions, 'allowAlottery', arr)
    this.$set(this.dictOptions, 'allowPoints', arr)
    this.$set(this.dictOptions, 'allowMemberDiscount', arr)
    let arr1 = [
      {text: this.$t('售价'), value: 'price'},
      {text: this.$t('币兑换值'), value: 'coin'},
      {text: this.$t('彩票兑换值'), value: 'lottery'},
      {text: this.$t('A票兑换值'), value: 'alottery'},
      {text: this.$t('A币兑换值'), value: 'points'},
      {text: this.$t('积分兑换值'), value: 'integral'}
    ]
    this.$set(this.dictOptions, 'typeList', arr1)
    if (!this.tenantid) {
      initDictOptions('bis_shop,name,code').then((res) => {
        if (res.success) {
          this.shops = res.result
          const shop = res.result.some(shop=>shop.value === '0')
          if(!shop){
            this.shops.unshift({ value: '0', title: this.$t('总部') })
          }
          this.shops.unshift({ value: '', title: this.$t('全部') })
        }
      })
      this.defColumns.splice(this.defColumns.length - 1, 0, {
        title: this.$t('所属门店'),
        align: 'left',
        dataIndex: 'tenantId',
        customRender: (t, r) => {
          let str
          if (!t) {
            str = this.$t('总部')
          } else {
            str = r.tenantId_dictText ? t + ' ' + r.tenantId_dictText : t
          }
          return str
        },
      })
    }else{
      if(this.taxSetting == 2){
        this.defColumns.splice(this.defColumns.length - 2, 0, {
          title: this.$t('其中税费'),
          align: 'right',
          dataIndex: 'taxPrice',
          customRender: (t, r) => {
            return t.toFixed(2)
          },
        })
      }
    }
    this.initDictConfig()
  },
  watch: {},
  computed: {
    tokenHeader() {
      let head = { 'X-Access-Token': Vue.ls.get(ACCESS_TOKEN) }
      let tenantid = Vue.ls.get(TENANT_ID)
      if (tenantid) {
        head['tenant-id'] = tenantid
      }
      return head
    },
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
    rowSelection() {
      let _this = this
      const { selectedRowKeys } = this
      return {
        selectedRowKeys,
        onChange: (selectedRowKeys, selectionRows) => {
          _this.onSelectChange(selectedRowKeys, selectionRows)
        },
        /* getCheckboxProps: (record) => ({
          props: {
            // 全部默认禁止选中
            // disabled: true,
            // 某几项默认禁止选中(R: 当state等于1时)
            disabled: record.tenantId != _this.tenantid , // 某几项默认选中(R: 当state等于1时) // defaultChecked: record.state == 1,
          },
        }), */
      }
    },
  },
  methods: {
    initDictConfig() {
      let that = this
      initDictOptions('bis_goods_infor.form').then((res) => {
        if (res.success) {
          that.list = res.result
          that.list.unshift({ value: '', title: that.$t('全部') })
          that.getSortList(that.list[0], 0)
          that.initColumns()
        }
      })
      that.$nextTick(() => {
        that.height = window.innerHeight - 200
      })
    },
    handleSizeChange(current, pageSize) {
      this.ipagination.pageSize = pageSize
    },
    handleToggleSearch() {
      this.toggleSearchStatus = !this.toggleSearchStatus
    },
    getGoodsList(num) {
      let that = this
      let querydata = {}
      that.ipagination.current = num
      that.queryParam.pageNo = that.ipagination.current
      that.queryParam.pageSize = that.ipagination.pageSize
      that.queryParam.parentKindId = that.treeItem
      that.queryParam.column = that.isorter.column
      that.queryParam.order = that.isorter.order
      querydata = that.queryParam
      that.loading = true
      getAction('/goods/bisGoodsInfor/list', querydata)
        .then((res) => {
          if (res.success) {
            that.dataSource = res.result.records
            that.dataSource.forEach((col) => {
              if (col.validityType == '0') {
                col.validityType_text = that.$t('不限期')
              } else if (col.validityType == '1') {
                col.validityType_text = col.startDate + '~' + col.endDate
              } else {
                col.validityType_text =
                  that.$t('领取后') + col.startDays + that.$t('天生效，有效期') + col.validDays + this.$t('天')
              }
            })
            if (res.result.total) {
              that.ipagination.total = res.result.total
            } else {
              that.ipagination.total = 0
            }
          }
        })
        .finally(() => {
          that.loading = false
        })
    },
    clickBatchEdit() {
      let arr = this.selectionRows.filter(s => {
        return s.tenantId == this.tenantid
      })
      if(arr.length!=this.batchList.length){
        this.$message.warning(this.$t('归属总部的商品请登录总部进行修改'))
      } else if (this.batchList.length > 0) {
        this.$refs.modalForm1.edit(this.batchList)
      } else {
        this.$message.warning(this.$t('请选择需要批量修改的商品'))
      }
    },
    clickBatchPrint() {
      if (this.batchList.length > 0) {
        this.$refs.batchPrint.edit(this.batchList)
      } else {
        this.$message.warning(this.$t('请选择需要批量打印的商品'))
      }
    },
    printSetting() {
      this.$refs.printSet.show()
    },
    modalFormOk() {
      this.getGoodsList(this.ipagination.current)
    },
    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectionRows = selectionRows
      this.batchList = []
      selectionRows.forEach((row) => {
        this.batchList.push(row.id)
      })
    },
    onClearSelected() {
      this.selectedRowKeys = []
      this.selectionRows = []
    },
    searchQuery() {
      this.getGoodsList(1)
      this.editingKey = ''
      this.selectedRowKeys = []
      this.selectionRows = []
    },
    edit(record, id) {
      let that = this
      if ((!record.tenantId && !that.tenantid) || record.tenantId == that.tenantid) {
        const newData = [...that.dataSource]
        const target = newData.filter((item) => id === item.id)[0]
        this.editingKey = id
        if (target) {
          target.editable = true
          this.dataSource = newData
        }
      }
    },
    save(id) {
      let that = this
      const newData = [...that.dataSource]
      const target = newData.filter((item) => id === item.id)[0]
      if (target) {
        delete target.editable
        let goods = {
          id: target.id,
          sort: target.sort,
        }
        putAction('/goods/bisGoodsInfor/editSort', goods).then((res) => {
          if (res.success) {
            that.$message.success(res.message)
            that.getGoodsList(that.ipagination.current)
          } else {
            that.$message.warning(res.message)
          }
        })
      }
      that.editingKey = ''
    },
    handleChangeSales() {
      delete this.queryParam.allowAlottery
      delete this.queryParam.allowCoin
      delete this.queryParam.allowIntegral
      delete this.queryParam.allowLottery
      delete this.queryParam.allowMemberDiscount
      delete this.queryParam.allowOut
      delete this.queryParam.allowPoints
      delete this.queryParam.allowSale
      delete this.queryParam.allowWarn
      switch (this.sales) {
        case 'allowAlottery':
          this.queryParam.allowAlottery = 'Y'
          break
        case 'allowCoin':
          this.queryParam.allowCoin = 'Y'
          break
        case 'allowIntegral':
          this.queryParam.allowIntegral = 'Y'
          break
        case 'allowLottery':
          this.queryParam.allowLottery = 'Y'
          break
        case 'allowMemberDiscount':
          this.queryParam.allowMemberDiscount = 'Y'
          break
        case 'allowOut':
          this.queryParam.allowOut = 'Y'
          break
        case 'allowPoints':
          this.queryParam.allowPoints = 'Y'
          break
        case 'allowSale':
          this.queryParam.allowSale = 'Y'
          break
        case 'allowWarn':
          this.queryParam.allowWarn = 'Y'
          break
        case 'allowRecycle':
          this.queryParam.allowRecycle = 'Y'
          break
      }
    },
    handleChange(value, id, column) {
      const newData = [...this.dataSource]
      const target = newData.filter((item) => id === item.id)[0]
      if (target) {
        target[column] = value
        this.dataSource = newData
      }
    },
    changeStatus(id, state) {
      if (state == 'Y') {
        state = 'N'
      } else if (state == 'N') {
        state = 'Y'
      }
      putAction('/goods/bisGoodsInfor/editState', { id: id, state: state }).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.getGoodsList(this.ipagination.current)
        } else {
          this.$message.warning(res.message)
        }
      })
    },
    getSortList(item) {
      let that = this
      that.rootItem = item
      that.sortList = []
      let param = {}
      param.pageNo = 1
      param.pageSize = 9999
      param.column = 'sort'
      param.order = 'asc'
      getAction('/goods/bisGoodsKind/rootList', param).then((res) => {
        if (res.success) {
          that.sortList = res.result.records
          if (that.sortList.length > 0) {
            that.sortList.forEach((col) => {
              col.key = '' + col.id
              col.value = '' + col.id
              col.title = '' + col.name
              col.id = '' + col.id
              col.pid = '' + col.pid
              col.hasChild = '' + col.hasChild
              if (col.hasChild != '0') {
                that.getHasChild(col)
              }
            })
            that.sortData = that.getDataByResult(that.sortList)
            that.sortData.unshift({ key: 0, id: '', title: that.$t('全部') })
            that.defaultSelectedKeys.push(that.sortData[0].key)
            that.treeItem = that.sortData[0].id
            that.getGoodsList(1)
          }
        }
      })
    },
    getHasChild(storage) {
      let that = this
      let query = {}
      query.pageNo = 1
      query.pageSize = 9999
      query.pid = storage.id
      getAction('/goods/bisGoodsKind/rootList', query).then((res) => {
        if (res.success) {
          if (res.result.records.length > 0) {
            res.result.records.forEach((col) => {
              col.key = '' + col.id
              col.value = '' + col.id
              col.title = '' + col.name
              col.pid = '' + col.pid
              col.id = '' + col.id
              col.hasChild = '' + col.hasChild
              if (col.hasChild != '0') {
                that.getHasChild(col)
              }
            })
            storage.children = that.getDataByResult(res.result.records)
            that.sortData = [...that.sortData]
          }
        } else {
          that.$message.warning(res.message)
        }
      })
    },
    getDataByResult(result) {
      let that = this
      return result.map((item) => {
        if (item.hasChild == 0 && item.key != '0') {
          that.allChildKind.push(item.key)
        }
        return item
      })
    },
    treeSelect(data) {
      this.treeItem = data[0]
      this.getGoodsList(1)
    },
    handleAdd(state, record) {
      let that = this
      record = that.rootItem.value
      that.visible1 = true
      initDictOptions('bis_goods_infor.form').then((res) => {
        if (res.success) {
          that.list1 = []
          let auth = localStorage.getItem('auth').split(',')
          res.result.forEach(function (item) {
            if (auth.indexOf('Form:physicalGoods:authorize') >= 0 && item.value == '1') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:rechargeCoin:authorize') >= 0 && item.value == '2') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:tickets:authorize') >= 0 && item.value == '3') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:yearTicket:authorize') >= 0 && item.value == '4') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:setMeal:authorize') >= 0 && item.value == '5') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:rxb:authorize') >= 0 && item.value == '8') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:coupon:authorize') >= 0 && item.value == '9') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:yylmGoods:authorize') >= 0 && item.value == '10') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:material:authorize') >= 0 && item.value == '11') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:transferredGoods:authorize') >= 0 && item.value == '12') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:rechargeACoin:authorize') >= 0 && item.value == '14') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:timeLimitCoin:authorize') >= 0 && item.value == '15') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:digitalCoin:authorize') >= 0 && item.value == '17') {
              that.list1.push(item)
            }
            if (auth.indexOf('Form:rechargeALottery:authorize') >= 0 && item.value == '18') {
              that.list1.push(item)
            }
          })
        }
      })
    },
    handleAdd1(state) {
      if (state == 9) {
        this.$refs.conponsForm.add(state)
        this.$refs.conponsForm.title = this.$t('新增优惠券')
        this.$refs.conponsForm.disableSubmit = false
      } else if (state == 14) {
        this.$refs.aCoinModalForm.add(state)
        this.$refs.aCoinModalForm.title = this.$t('新增')
        this.$refs.aCoinModalForm.disableSubmit = false
      } else if (state == 15) {
        this.$refs.timeLimitCoin.add(state)
        this.$refs.timeLimitCoin.title = this.$t('新增')
        this.$refs.timeLimitCoin.disableSubmit = false
      } else if (state == 5) {
        this.$refs.goodsInfoMeal.add(state)
        this.$refs.goodsInfoMeal.title = this.$t('新增')
        this.$refs.goodsInfoMeal.disableSubmit = false
      } else if (state == 17) {
        this.$refs.digitalCoin.add(state)
        this.$refs.digitalCoin.title = this.$t('新增')
        this.$refs.digitalCoin.disableSubmit = false
      } else if (state == 18) {
        this.$refs.aLotteryModalForm.add(state)
        this.$refs.aLotteryModalForm.title = this.$t('新增')
        this.$refs.aLotteryModalForm.disableSubmit = false
      } else if(state == 1) {
        if(JSON.parse(localStorage.getItem('isChain')) && this.tenantid){
          const h = this.$createElement;
          this.$confirm({
            title: this.$t('友情提示'),
            content: h('div', {}, [
              h('p', this.$t('您当前的服务器为连锁模式，可在总部管理商品资料，各分店共享使用，以避免各店公用的商品还得每个门店都添加一遍的繁琐操作；若无需总部统一管理则仍可继续添加本店独有的商品。')),
            ]),
            cancelText: this.$t('考虑一下'),
            okText: this.$t('继续添加'),
            onOk:()=> {
              this.$refs.modalForm.add(state)
              this.$refs.modalForm.title = this.$t('新增')
              this.$refs.modalForm.disableSubmit = false
            },
          })
        }else{
          this.$refs.modalForm.add(state)
          this.$refs.modalForm.title = this.$t('新增')
          this.$refs.modalForm.disableSubmit = false
        }
      } else{
        this.$refs.modalForm.add(state)
        this.$refs.modalForm.title = this.$t('新增')
        this.$refs.modalForm.disableSubmit = false
      }
    },
    handleCancel1() {
      this.visible1 = false
    },
    handleEdit(record, state) {
      if (record.form == 5) {
        this.$refs.goodsInfoMeal.edit(record, state)
        this.$refs.goodsInfoMeal.title = this.$t('编辑')
        this.$refs.goodsInfoMeal.disableSubmit = false
      } else if (record.form == 17) {
        this.$refs.digitalCoin.edit(record, state)
        this.$refs.digitalCoin.title = this.$t('编辑')
        this.$refs.digitalCoin.disableSubmit = false
      } else if (record.form == 18) {
        this.$refs.aLotteryModalForm.edit(record, state)
        this.$refs.aLotteryModalForm.title = this.$t('编辑')
        this.$refs.aLotteryModalForm.disableSubmit = false
      } else {
        this.$refs.modalForm.edit(record, state)
        this.$refs.modalForm.title = this.$t('编辑')
        this.$refs.modalForm.disableSubmit = false
      }
    },
    handleEditCon(record, state) {
      this.$refs.conponsForm.edit(record, state)
      this.$refs.conponsForm.title = this.$t('编辑')
      this.$refs.conponsForm.disableSubmit = false
    },
    handleEditACoin(record, state) {
      this.$refs.aCoinModalForm.edit(record, state)
      this.$refs.aCoinModalForm.title = this.$t('编辑')
      this.$refs.aCoinModalForm.disableSubmit = false
    },
    handleEditTimeLimitCoin(record, state) {
      this.$refs.timeLimitCoin.edit(record, state)
      this.$refs.timeLimitCoin.title = this.$t('编辑')
      this.$refs.timeLimitCoin.disableSubmit = false
    },
    handleEditToken(record, state) {
      this.$refs.tokenForm.edit(record, state)
      this.$refs.tokenForm.title = this.$t('编辑')
      this.$refs.tokenForm.disableSubmit = false
    },
    handleEditCard(record, state) {
      this.$refs.cardForm.edit(record, state)
      this.$refs.cardForm.title = this.$t('编辑')
      this.$refs.cardForm.disableSubmit = false
    },
    //列设置更改事件
    onColSettingsChange(checkedValues) {
      var key = this.$route.name + ':colsettings'
      Vue.ls.set(key, checkedValues, 7 * 24 * 60 * 60 * 1000)
      this.settingColumns = checkedValues
      const cols = this.defColumns.filter((item) => {
        if (item.key == 'rowIndex' || item.dataIndex == 'action') {
          return true
        }
        if (this.settingColumns.includes(item.dataIndex)) {
          return true
        }
        return false
      })
      this.columns = cols
    },
    handleDelete(id) {
      var that = this
      if (!that.url.delete) {
        that.$message.error(that.$t('请设置url.delete属性'))
        return
      }
      deleteAction(that.url.delete, { id: id }).then((res) => {
        if (res.success) {
          //重新计算分页问题
          that.reCalculatePage(1)
          that.$message.success(res.message)
          that.getGoodsList(1)
        } else {
          that.$message.warning(res.message)
        }
      })
    },
    handleTableChange(pagination, filters, sorter) {
      if (Object.keys(sorter).length > 0) {
        this.isorter.column = sorter.field
        this.isorter.order = 'ascend' == sorter.order ? 'asc' : 'desc'
      }
      this.getGoodsList(pagination.current)
    },
    initColumns() {
      //权限过滤（列权限控制时打开，修改第二个参数为授权码前缀）
      //this.defColumns = colAuthFilter(this.defColumns,'testdemo:');
      var key = this.$route.name + ':colsettings'
      let colSettings = Vue.ls.get(key)
      let arr = ['allowCoin','coin','allowLottery','lottery','allowAlottery','alottery','allowPoints','points','allowIntegral','integral']
      if (colSettings == null || colSettings == undefined) {
        let allSettingColumns = [], settingColumns = [], columns = []
        this.defColumns.forEach(function (item, i, array) {
          allSettingColumns.push(item.dataIndex)
          if(arr.indexOf(item.dataIndex)==-1){
            settingColumns.push(item.dataIndex)
            columns.push(item)
          }
        })
        this.settingColumns = settingColumns
        this.columns = columns
      } else {
        this.settingColumns = colSettings
        const cols = this.defColumns.filter((item) => {
          if (item.key == 'rowIndex' || item.dataIndex == 'action') {
            return true
          }
          if (colSettings.includes(item.dataIndex)) {
            return true
          }
          return false
        })
        this.columns = cols
      }
    },
    handleReset() {
      this.queryParam = {
        goodsInfo: '',
        form: '',
        state: '',
        notSystem: 1,
        tenantId: '',
        newType: 'price'
      }
      this.treeItem = this.sortData[0].id
      this.sales = ''
      this.defaultSelectedKeys.push(this.sortData[0].key)
      this.getGoodsList(1)
    },
    getImgView(text) {
      if (text && text.indexOf(',') > 0) {
        text = text.substring(0, text.indexOf(','))
      }
      return getFileAccessHttpUrl(text)
    },
    reCalculatePage(count) {
      //总数量-count
      let total = this.ipagination.total - count
      //获取删除后的分页数
      let currentIndex = Math.ceil(total / this.ipagination.pageSize)
      //删除后的分页数<所在当前页
      if (currentIndex < this.ipagination.current) {
        this.ipagination.current = currentIndex
      }
    },
    getQueryField() {
      //TODO 字段权限控制
      var str = 'id,'
      this.columns.forEach(function (value) {
        str += ',' + value.dataIndex
      })
      return str
    },
    handleExportXls(fileName) {
      if (!fileName || typeof fileName != 'string') {
        fileName = this.$t('导出文件')
      }
      let param = {}
      //this.queryParam.form = this.rootItem.value
      this.queryParam.parentKindId = this.treeItem
      this.queryParam.column = this.isorter.column
      this.queryParam.order = this.isorter.order
      param = this.queryParam
      if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
        param['selections'] = this.selectedRowKeys.join(',')
      }
      downFile(this.url.exportXlsUrl, param).then((data) => {
        if (!data) {
          this.$message.warning(this.$t('文件下载失败'))
          return
        }
        if (typeof window.navigator.msSaveBlob !== 'undefined') {
          window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
        } else {
          let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
          let link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', fileName + '.xls')
          document.body.appendChild(link)
          link.click()
          document.body.removeChild(link) //下载完成移除元素
          window.URL.revokeObjectURL(url) //释放掉blob对象
        }
      })
    },
    /* 导入弹窗 */
    getImport() {
      if(JSON.parse(localStorage.getItem('isChain')) && this.tenantid){
        const h = this.$createElement;
        this.$confirm({
          title: this.$t('友情提示'),
          content: h('div', {}, [
            h('p', this.$t('您当前的服务器为连锁模式，可在总部管理商品资料，各分店共享使用，以避免各店公用的商品还得每个门店都添加一遍的繁琐操作；若无需总部统一管理则仍可继续添加本店独有的商品。')),
          ]),
          cancelText: this.$t('考虑一下'),
          okText: this.$t('继续导入'),
          onOk:()=> {
            this.visible = true
            this.ruleForm = {
              filename: '',
              name: '',
            }
          },
        })
      }else{
        this.visible = true
        this.ruleForm = {
          filename: '',
          name: '',
        }
      }
    },
    /* 下载模板 */
    download(fileName) {
      if (!fileName || typeof fileName != 'string') {
        fileName = this.$t('导出文件')
      }
      let url = window._CONFIG['domianURL'] + 'importTemplate/商品资料导入模板.xls'
      let link = document.createElement('a')
      link.style.display = 'none'
      link.href = url
      link.download = fileName
      document.body.appendChild(link)
      link.click()
      document.body.removeChild(link) //下载完成移除元素
      window.URL.revokeObjectURL(url) //释放掉blob对象
      return
    },
    /* 导入 */
    handleImportExcel1(info) {
      if (info.file.status !== 'uploading') {
        this.ruleForm.name = info.file.name
        this.ruleForm.filename = info.file.response.message
      }
      if (info.file.status === 'done') {
        if (info.file.response.success) {
          if (info.file.response.code === 201) {
            let {
              message,
              result: { msg, fileUrl, fileName },
            } = info.file.response
            let href = window._CONFIG['domianURL'] + fileUrl
          } else {
            this.$message.success(info.file.response.message || `${info.file.name} ` + this.$t('文件上传成功'))
          }
        } else {
          this.$message.error(`${info.file.name} ${info.file.response.message}.`)
        }
      } else if (info.file.status === 'error') {
        this.$message.error(this.$t('文件上传失败') + ': ' ` ${info.file.msg} `)
      }
    },
    /* 弹窗确定 */
    handleOk(e) {
      let that = this
      that.$refs.ruleForm.validate((valid) => {
        if (valid) {
          that.confirmLoading = true
          that.cancelbutton = { props: { disabled: true } }
          const params = {
            filename: that.ruleForm.filename,
          }
          UploadFile('/goods/bisGoodsInfor/importExcel', params).then((res) => {
            if (res.success) {
              setTimeout(() => {
                ;(that.cancelbutton = { props: { disabled: false } }), (that.confirmLoading = false)
                that.visible = false
                that.$message.success(res.message)
                that.loadData(1)
              }, 1000)
            } else {
              that.$message.error(res.message)
              setTimeout(() => {
                ;(that.cancelbutton = { props: { disabled: false } }), (that.confirmLoading = false)
              }, 1000)
            }
          })
        } else {
          that.$message.warning(that.$t('请检查输入项'))
          return false
        }
      })
    },
    /* 弹窗取消 */
    handleCancel() {
      this.visible = false
      this.$refs.ruleForm.resetFields()
    },
    batchDel() {
      let that = this
      let arr = that.selectionRows.filter(s => {
        return s.tenantId == that.tenantid
      })
      if(arr.length!=that.batchList.length){
        that.$message.warning(that.$t('归属总部的商品请登录总部进行删除'))
      } else
      if (that.selectedRowKeys.length <= 0) {
        that.$message.warning(that.$t('请选择要删除的商品'))
        return
      } else {
        let ids = that.selectedRowKeys.join(',')
        that.$confirm({
          title: that.$t('确认'),
          content: that.$t('您确定要删除已选择的商品吗？'),
          okText: that.$t("确定"),
          cancelText: that.$t("取消"),
          onOk: function () {
            that.loading = true
            deleteAction(that.url.deleteBatch, { ids: ids })
              .then((res) => {
                if (res.success) {
                  that.$message.success(res.message)
                  that.searchQuery(1)
                  that.selectedRowKeys = []
                } else {
                  that.$message.warning(res.message)
                }
              })
              .finally(() => {
                that.loading = false
              })
          },
        })
      }
    },
  },
}
</script>
<style>
.top-col {
  text-align: center;
  height: 60px;
  line-height: 60px;
  border-radius: 5px;
  margin: 0 20px 15px 20px;
  font-size: 16px;
  color: #ffff;
  background-color: #eb5467;
}
</style>
<style scoped>
@import '~@assets/less/common.less';
</style>